# -*- coding: utf-8 -*-
from datetime import datetime

from src.com.ydzy.util.base_util import BaserUtil, record_time
from src.com.ydzy.util.http_util import HttpClient

http_client = HttpClient()
base_client=BaserUtil()


param={
    "sysId": "8c937c8e48d14ca0b28293197a231888",
    # "sysId": "da0bb3a9bfff4bf0909d5de48dcd5288",
    "logType": "09",
    # "logType": "666565",
    "logContents": [
        "{\"defineId\":9982,\"upflow\":\"10\",\"downflow\":56,\"outterUrl\":\"http://zt.gat.gz/zt/v1/token/validateapptoken\",\"innerUrl\":\"http://cc.gat.gz:8080/zt/v1/token/validateapptoken\",\"errorCode\":\"0\",\"errorMsg\":\"成功\",\"responseCode\":\"200\",\"subject\":\"A-1504061\",\"object\":\"1251\",\"userToken\":\"\",\"operateType\":\"090000\",\"checkSum\":\"098ffd02d65a146a3716f1c2d2df65cc0de57f77c196e03662177854ea3f9a10\",\"businessIp\":\"zt.gat.gz\",\"terminal\":\"192.168.8.82\",\"checkPoint\":\"A-1504061\",\"ccUuid\":\"A-1504061-65daa59e-00070fff\",\"flow\":%s,\"duration\":5,\"content\":\"http://cc.gat.gz:8080/zt/v1/token/validateapptoken\",\"dataLevel\":\"000\",\"testField2\":\"15415215215\",\"sysId\":\"sysId->123\",\"appToken\":\"443baa405965469e99670b4a76ed42a2\"}",
    ],
    "checkSum": "73fcd834c37149f5954f19b526517a48cc811ea81e47ac6773c939cce2444789",
    "sign":"dev-rc-28-dev-24-0611"
}




url='http://localhost:20028/auditcenter/audit_logs'
url='https://audit.gat.gz/auditcenter/audit_logs'

headers={
    "RZZX-APPTOKEN":"jg1.02ff905a587e4e97bb9666925f28a948"
}
@record_time
def method_name(url,param):
    res = http_client.post(url=url, data=param,headers={},fast_falg=True)

@record_time
def main(total):
    for i in range(total):
        single_method(i, total)
    print("main方法--->" ,end="\t")


def single_method(i, total):
    param_copy = base_client.deep_copy(param)
    param_copy['logContents'][0] = param_copy['logContents'][0] % i
    res = method_name(url=url, param=param_copy)
    formatted_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    print(f"{formatted_time}-->当前第{i}次总数为{total}次当前完成进度为{(((i + 1) / total)) * 100}%")


if __name__=='__main__':
    total = 10
    main(total)

